package com.pzhu.servlet;

import com.pzhu.pojo.Book;
import com.pzhu.service.BookService;
import com.pzhu.service.impl.BookServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class BookShowServlet extends HttpServlet {
	private BookService bs=new BookServiceImpl();
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		req.setCharacterEncoding("utf-8");
		resp.setContentType("text/html;charset=utf-8");
		
		List<Book> list=bs.showBooks();
		if(list==null){
			System.out.println("nullֵ");
		}else{
			System.out.println(list);
			}
		

		req.setAttribute("list", list);
		System.out.println(list);
		req.getRequestDispatcher("/view/jsp/showbooks.jsp").forward(req, resp);
//		req.getRequestDispatcher("/view/jsp/showbooks2.jsp").forward(req, resp);
		return;
		
	}
}
